<template>
  <div class="apiBox">
    <!--header-->
    <div class="apiHeader selectBlock flexTitlePadding">
      <div class="viewBoxTitle flexTitle">
        <span>API 研发管理</span>
      </div>
      <div class="headerBtnAll" v-if="addapi">
        <el-button size="small" type="primary" @click="handelClickAddData">新建数据结构</el-button>
        <el-button type="text"  class="headerBtn btnItem" @click="batch"><i class="iconfont">&#xe605;</i><span class="headerBtnSize" >批量操作</span></el-button>
      </div>
      <div class="apiContentBoxHeader1" v-else>
        <el-button  type="text" @click="batchcancel"><i class="el-icon-back"></i> &nbsp&nbsp取消 &nbsp&nbsp|</el-button>
        <el-button type="text" :disabled='disabledButton' @click="databulkdelete">删除 &nbsp&nbsp|</el-button>
      </div>
    </div>
    <!--content-->
    <div class="elementTableBox apiContent">
      <el-table
        :data="tableData"
        size="small"
        stripe
        class="elementTable"
        header-cell-class-name="elementTableHeader"
        cell-class-name="elementTableBody"
        @selection-change="changeFun"
        highlight-current-row>
        <el-table-column type="selection" width="55" v-if="addapi==false"></el-table-column>
        <el-table-column align="center" label='数据结构 ( 数据类型 )' prop="name"></el-table-column>
        <el-table-column align="center" label="描述" prop="remarks"></el-table-column>
        <el-table-column align="center" label="类型" prop="type"></el-table-column>
        <el-table-column align="center" label="操 作" width="260" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <div class="tableOperatuib">
              <el-button type="text" v-if="scope.row.isQuoted==1"  @click="seeView(scope.row)">查看引用</el-button>
              <el-button type="text" @click="Editdatastructure(scope.row)">编辑</el-button>
              <el-button type="text" @click="datadelete(scope.row)">删除</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!--dialog 新建数据结构-->
    <el-dialog
      v-if="dialogVisibleAddGroup"
      custom-class="dhcWebLayer"
      top="0"
      :close-on-click-modal="false"
      title="新建数据结构"
      :visible.sync="dialogVisibleAddGroup"
      width="70%">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="名称" prop="name">
          <el-input size="small" v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="描述" prop="remarks">
          <el-input size="small" v-model="ruleForm.remarks"></el-input>
        </el-form-item>
        <el-form-item label="类型">
          <el-radio-group v-model="ruleForm.type">
            <el-radio label="FormData">FormData</el-radio>
            <el-radio label="JSON">JSON</el-radio>
            <el-radio label="XML">XML</el-radio>
            <el-radio label="Array">Array</el-radio>
            <el-radio label="Object">Object</el-radio>
            <!--<el-radio label="Enum">Enum</el-radio>-->
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <div>
            <indexTable v-if="ruleForm.type === 'FormData'"  ref="dataStructureFormData" title="参数名" :list="dataStructureFormData" :tableBtn="btnFormData" @handlerExpand="handlerExpand" @handelClickRowEdit="handelClickRowEdit"></indexTable>
          </div>
          <div>
            <indexTable v-if="ruleForm.type === 'JSON'" ref="dataStructureJSON" title="参数名" :list="dataStructureJSON" :tableBtn="btnJSON" @handlerExpand="handlerExpand" @handelClickRowEdit="handelClickRowEdit"></indexTable>
          </div>
          <div>
            <indexTable v-if="ruleForm.type === 'XML'" ref="dataStructureXML" title="参数名" :list="dataStructureXML" :tableBtn="btnJSON" @handlerExpand="handlerExpand" @handelClickRowEdit="handelClickRowEdit"></indexTable>
          </div>
          <div>
            <indexTable v-if="ruleForm.type === 'Array'" ref="dataStructureArray" title="参数名" :list="dataStructureArray" :tableBtn="btnJSON" @handlerExpand="handlerExpand" @handelClickRowEdit="handelClickRowEdit"></indexTable>
          </div>
          <div>
            <indexTable v-if="ruleForm.type === 'Object'" ref="dataStructureObject" title="参数名" :list="dataStructureObject" :tableBtn="btnJSON" @handlerExpand="handlerExpand" @handelClickRowEdit="handelClickRowEdit"></indexTable>
          </div>
        </el-form-item>
      </el-form>
      <div style="text-align: right;">
        <el-button size="small" type="primary" @click="saveClickFun">保 存</el-button>
        <el-button size="small" @click="dialogVisibleAddGroup = false">取 消</el-button>
      </div>
    </el-dialog>
    <!--dialog 编辑数据结构-->
    <el-dialog
      v-if="dialogVisibleEditGroup"
      custom-class="dhcWebLayer"
      top="0"
      :close-on-click-modal="false"
      title="编辑数据结构"
      :visible.sync="dialogVisibleEditGroup"
      width="70%">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="名称" prop="name">
          <el-input size="small" v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="描述" prop="remarks">
          <el-input size="small" v-model="ruleForm.remarks"></el-input>
        </el-form-item>
        <el-form-item label="类型">
          <el-radio-group v-model="ruleForm.type">
            <el-radio label="FormData">FormData</el-radio>
            <el-radio label="JSON">JSON</el-radio>
            <el-radio label="XML">XML</el-radio>
            <el-radio label="Array">Array</el-radio>
            <el-radio label="Object">Object</el-radio>
            <!--<el-radio label="Enum">Enum</el-radio>-->
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <div>
            <indexTable v-if="ruleForm.type === 'FormData'" ref="dataStructureFormData" title="参数名" :list="dataStructureFormData" :tableBtn="btnFormData" @handlerExpand="handlerExpand" @handelClickRowEdit="handelClickRowEdit"></indexTable>
          </div>
          <div>
            <indexTable v-if="ruleForm.type === 'JSON'" ref="dataStructureJSON" title="参数名" :list="dataStructureJSON" :tableBtn="btnJSON" @handlerExpand="handlerExpand" @handelClickRowEdit="handelClickRowEdit"></indexTable>
          </div>
          <div>
            <indexTable v-if="ruleForm.type === 'XML'" ref="dataStructureXML" title="参数名" :list="dataStructureXML" :tableBtn="btnJSON" @handlerExpand="handlerExpand" @handelClickRowEdit="handelClickRowEdit"></indexTable>
          </div>
          <div>
            <indexTable v-if="ruleForm.type === 'Array'" ref="dataStructureArray" title="参数名" :list="dataStructureArray" :tableBtn="btnJSON" @handlerExpand="handlerExpand" @handelClickRowEdit="handelClickRowEdit"></indexTable>
          </div>
          <div>
            <indexTable v-if="ruleForm.type === 'Object'" ref="dataStructureObject" title="参数名" :list="dataStructureObject" :tableBtn="btnJSON" @handlerExpand="handlerExpand" @handelClickRowEdit="handelClickRowEdit"></indexTable>
          </div>
        </el-form-item>
      </el-form>
      <div style="text-align: right;">
        <el-button size="small" type="primary" @click="Editdatastructuresave">保 存</el-button>
        <el-button size="small" @click="dialogVisibleEditGroup = false">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog
      v-if="dialogVisibleseeView"
      custom-class="dhcWebLayer"
      top="0"
      :close-on-click-modal="false"
      title="数据结构"
      :visible.sync="dialogVisibleseeView"
      width="30%">
      <el-table
        :data="datatableData"
        size="small"
        stripe
        class="elementTable"
        header-cell-class-name="elementTableHeader"
        cell-class-name="elementTableBody"
        highlight-current-row>
        <el-table-column prop="name" label="APIS" ></el-table-column>
        <el-table-column prop="version" label="版本号" ></el-table-column>
        <el-table-column label="操作" width="200">
          <template slot-scope="scope">
           <el-button type="text" @click="jumpAPI(scope.row)">跳转到该API</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div style="margin-top: 16px;text-align: right;">
        <el-button size="small" @click="dialogVisibleseeView = false">关闭</el-button>
      </div>
    </el-dialog>
    </div>
</template>

<script>
  import {
    addApiDataStructure,
    getdatastructureList,
    Editdatastructure,
    Editdatastructuresave,
    datadelete,
    databulkdelete,
    viewReferences
  } from '@/api/apiModel/api.js'
  import indexTable from '@/components/dhcTable/indexTable'
  export default {
    name: 'dataStructure',
    components: {
      indexTable
    },
    data() {
      return {
        btnFormData: {
          insert: true,
          addSubfield: false,
          insertDataStructure: true,
          delete: true
        },
        btnJSON: {
          insert: true,
          addSubfield: true,
          insertDataStructure: false,
          delete: true
        },
        dataStructuretype: '',
        apiIds: [], // 批量存储ID数组
        dialogVisibleseeView: false,
        disabledButton: true,
        datatableData: [], // 查看引用数组
        addapi: true,
        editRowIdReq: '',
        addRowIdReq: '',
        childrenIdReq: '',
        childrenParentIdReq: '',
        formDataReq: {
          parameterName: '',
          type: '',
          required: true,
          explain: '',
          limit: '',
          example: ''
        },
        dialogConfigReq: false,
        requestBodyTableXML: [
          {
            id: 'BS6Y96XB7OB9WZDJ2J3CXSD75YMK2X',
            parameterName: '',
            type: '',
            required: true,
            explain: '',
            limit: '',
            example: '',
            parentId: '****',
            children: []
          }
        ],
        columnsReq: [
          {
            label: '参数名',
            prop: 'parameterName',
            width: '200',
            align: 'left',
            headerAlign: 'center',
            type: 'template',
            template: 'parameterName'
          },
          {
            label: '类型',
            prop: 'type',
            align: 'center',
            headerAlign: 'center',
            type: 'template',
            template: 'type'
          },
          {
            label: '必填',
            prop: 'required',
            align: 'center',
            headerAlign: 'center',
            type: 'template',
            template: 'required'
          },
          {
            label: '说明',
            prop: 'explain',
            align: 'center',
            headerAlign: 'center',
            type: 'template',
            template: 'explain'
          },
          {
            label: '限制',
            prop: 'limit',
            align: 'center',
            headerAlign: 'center',
            type: 'template',
            template: 'limit'
          },
          {
            label: '示例',
            prop: 'example',
            align: 'center',
            headerAlign: 'center',
            type: 'template',
            template: 'example'
          },
          {
            label: '更多操作',
            align: 'center',
            width: '300',
            headerAlign: 'center',
            type: 'template',
            template: 'empower'
          }
        ],
        optionsType: [
          {
            value: 'string',
            label: '[string]'
          }, {
            value: 'array',
            label: '[array]'
          }, {
            value: 'object',
            label: '[object]'
          }, {
            value: 'int',
            label: '[int]'
          }
        ],
        parentIdDataReq: '',
        charsReq: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
        dataStructureFormData: [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ],
        dataStructureJSON: [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ],
        dataStructureXML: [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ],
        dataStructureArray: [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ],
        dataStructureObject: [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ],
        requestBodyTableFormData: [
          {
            addRow: true,
            parameterName: '',
            type: '',
            required: true,
            explain: '',
            limit: '',
            example: ''
          }
        ],
        dialogVisibleAddGroup: false,
        dialogVisibleEditGroup: false,
        ruleForm: {
          name: '',
          remarks: '',
          type: 'FormData'
        },
        rules: {
          name: [
            { required: true, message: '请填写名称', trigger: 'blur' }
          ],
          remarks: [
            { required: true, message: '请填写描述', trigger: 'blur' }
          ]
        },
        datastructureList: {
          'condition': [
          ],
          'sort': [
            {
              'direction': 'DESC',
              'property': 'ctime'
            }
          ],
          'fields': []
        },
        postList: {},
        tableData: [] // 定义表格数据
      }
    },
    mounted() {
      // 查询
      this.fetchData()
    },
    methods: {
      // insertStructure() {
      //   this.dataStructuretype = this.ruleForm.type
      // },
      seeView(row) {
        this.dialogVisibleseeView = true
        viewReferences(this.datastructureList, row.id).then(res => {
          this.datatableData = res.data.data.records
        })
      },
      jumpAPI(row) {
        this.$router.push({
          name: 'editApiPage',
          query: {
            id: row.apiId
          }
        })
      },
      // 选择复选框
      changeFun(val) {
        this.apiIds = []
        if (this.tableData.length > 0) {
          for (var i = 0; i < val.length; i++) {
            this.apiIds.push(val[i].id)
          }
        }
        if (val.length > 0) {
          this.disabledButton = false
        } else {
          this.disabledButton = true
        }
      },
      batch() {
        this.addapi = false
      },
      batchcancel() {
        this.addapi = true
      },
      fetchData() {
        getdatastructureList(this.datastructureList, 0, '').then(res => {
          this.tableData = res.data.data.records
        })
      },
      Editdatastructure(row) {
        this.dataStructureFormData = [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ]
        this.dataStructureJSON = [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ]
        this.dataStructureXML = [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ]
        this.dataStructureArray = [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ]
        this.dataStructureObject = [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ]
        Editdatastructure(row.id).then(res => {
          this.ruleForm = res.data.data
          if (this.ruleForm.type === 'FormData') {
            this.dataStructureFormData = res.data.data.content
          } else if (this.ruleForm.type === 'JSON') {
            this.dataStructureJSON = res.data.data.content
          } else if (this.ruleForm.type === 'XML') {
            this.dataStructureXML = res.data.data.content
          } else if (this.ruleForm.type === 'Array') {
            this.dataStructureArray = res.data.data.content
          } else if (this.ruleForm.type === 'Object') {
            this.dataStructureObject = res.data.data.content
          }
          this.dialogVisibleEditGroup = true
        })
      },
      datadelete(row) {
        // 删除
        this.$confirm('此操作无法恢复，确认操作？', '永久性删除所选数据结构', { type: 'warning' }).then(() => {
          const deleteform = {
            ids: [row.id]
          }
          datadelete(deleteform).then(res => {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.fetchData()
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      },
      databulkdelete() {
        // 批量删除
        this.$confirm('此操作无法恢复，确认操作？', '永久性删除所选数据结构', { type: 'warning' }).then(() => {
          const deleteform = {
            ids: this.apiIds
          }
          databulkdelete(deleteform).then(res => {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.fetchData()
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      },
      handlerExpand(row) {
        console.log(row)
        row.isExpand = !row.isExpand
      },
      handelClickRowEdit(row, oldRow) {
        if (row.id === oldRow.id) {
          row.editRow = false
          oldRow.editRow = false
        } else {
          row.editRow = true
          oldRow.editRow = false
        }
      },
      removeTableRowReq(row, index) {
        const newArr = this.filterReq(this.requestBodyTableXML, row.id)
        this.requestBodyTableXML = newArr
      },
      filterReq(data, id) {
        const _this = this
        var newData = data.filter(x => x.id !== id)
        newData.forEach(x => x.children && (x.children = _this.filterReq(x.children, id)))
        return newData
      },
      generateMixedReq(n) {
        var res = ''
        for (var i = 0; i < n; i++) {
          var id = Math.ceil(Math.random() * 35)
          res += this.charsReq[id]
        }
        return res
      },
      dataForEachFunReq(data) {
        const _this = this
        data.forEach((val, index) => {
          if (val.id === _this.editRowIdReq) {
            val.parameterName = _this.formDataReq.parameterName
            val.type = _this.formDataReq.type
            val.required = _this.formDataReq.required
            val.explain = _this.formDataReq.explain
            val.limit = _this.formDataReq.limit
            val.example = _this.formDataReq.example
          } else if (val.children.length !== 0) {
            _this.dataForEachFunReq(val.children)
          }
        })
      },
      saveDialogConfigReq() {
        this.dataForEachFunReq(this.requestBodyTableXML)
        console.log(this.requestBodyTableXML)
        this.dialogConfigReq = false
      },
      childrenForEachFunReq(data) {
        const _this = this
        data.forEach((val, index) => {
          console.log(val.children)
          console.log(val.id)
          if (val.id === _this.childrenIdReq) {
            val.children.push({
              id: _this.generateMixedReq(30),
              parentId: _this.childrenParentIdReq,
              parameterName: '',
              type: '',
              required: true,
              explain: '',
              limit: '',
              example: '',
              children: []
            })
          } else if (val.children.length !== 0) {
            console.log('有子集')
            _this.childrenForEachFunReq(val.children)
          }
        })
      },
      configCanshuReq(row, index, val) {
        this.editRowIdReq = row.id
        this.formDataReq.parameterName = row.parameterName
        this.formDataReq.type = row.type
        this.formDataReq.required = row.required
        this.formDataReq.explain = row.explain
        this.formDataReq.limit = row.limit
        this.formDataReq.example = row.example
        this.dialogConfigReq = true
      },
      addFieldChildrenReq(row, index) {
        console.log(this.requestBodyTableXML)
        this.childrenIdReq = row.id
        this.childrenParentIdReq = row.id
        this.childrenForEachFunReq(this.requestBodyTableXML)
      },
      addForEachFunReq(data) {
        const _this = this
        data.forEach((val, index) => {
          if (val.id === _this.parentIdDataReq) {
            console.log(val)
            val.children.push({
              id: _this.generateMixedReq(30),
              parentId: _this.parentIdDataReq,
              parameterName: '',
              type: '',
              required: true,
              explain: '',
              limit: '',
              example: '',
              children: []
            })
          } else if (val.children.length !== 0) {
            _this.addForEachFunReq(val.children)
          }
        })
      },
      addRowDataReq(row, index) {
        const _this = this
        this.parentIdDataReq = row.parentId
        console.log(row)
        if (row.parentId === '****') {
          this.requestBodyTableXML.splice(index, 0, {
            id: _this.generateMixedReq(30),
            parentId: '****',
            parameterName: '',
            type: '',
            required: true,
            explain: '',
            limit: '',
            example: '',
            children: []
          })
        } else {
          console.log('不是根节点')
          this.addForEachFunReq(this.requestBodyTableXML)
        }
      },
      saveClickFun() {
        this.postList = this.ruleForm
        if (this.ruleForm.type === 'FormData') {
          this.postList.content = this.$refs.dataStructureFormData.getTableData()
        } else if (this.ruleForm.type === 'JSON') {
          this.postList.content = this.$refs.dataStructureJSON.getTableData()
        } else if (this.ruleForm.type === 'XML') {
          this.postList.content = this.$refs.dataStructureXML.getTableData()
        } else if (this.ruleForm.type === 'Array') {
          this.postList.content = this.$refs.dataStructureArray.getTableData()
        } else if (this.ruleForm.type === 'Object') {
          this.postList.content = this.$refs.dataStructureObject.getTableData()
        }
        console.log(this.postList)
        addApiDataStructure(this.postList).then(res => {
          this.fetchData()
          this.$message({
            message: '新建成功',
            type: 'success'
          })
          this.dialogVisibleAddGroup = false
        })
      },
      Editdatastructuresave() {
        this.postList = this.ruleForm
        if (this.ruleForm.type === 'FormData') {
          this.postList.content = this.$refs.dataStructureFormData.getTableData()
        } else if (this.ruleForm.type === 'JSON') {
          this.postList.content = this.$refs.dataStructureJSON.getTableData()
        } else if (this.ruleForm.type === 'XML') {
          this.postList.content = this.$refs.dataStructureXML.getTableData()
        } else if (this.ruleForm.type === 'Array') {
          this.postList.content = this.$refs.dataStructureArray.getTableData()
        } else if (this.ruleForm.type === 'Object') {
          this.postList.content = this.$refs.dataStructureObject.getTableData()
        }
        Editdatastructuresave(this.postList, this.ruleForm.id).then(res => {
          this.fetchData()
          this.$message({
            message: '编辑成功',
            type: 'success'
          })
          this.dialogVisibleEditGroup = false
        })
      },
      handelClickAddData() {
        this.dialogVisibleAddGroup = true
        this.ruleForm = {
          name: '',
          remarks: '',
          type: 'FormData'
        }
        this.dataStructureFormData = [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ]
        this.dataStructureJSON = [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ]
        this.dataStructureXML = [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ]
        this.dataStructureArray = [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ]
        this.dataStructureObject = [
          {
            id: '10000',
            parentId: null,
            parameterName: '',
            type: 'string',
            required: true,
            example: '',
            explain: '',
            limit: '',
            children: []
          }
        ]
      },
      tableRowDataChange(val, row, tableDom) {
        switch (tableDom) {
          case 'tableData':
            if (row.addRow) {
              row.addRow = false
              this.tableData.push({
                type: 0, // 类型（0请求head，1返回head）
                headerName: '', // 标签
                required: true, // 必填
                headerValue: '', // 示例
                remarks: '', // 说明
                addRow: true
              })
            }
            break
          case 'requestBodyTableFormData':
            if (row.addRow) {
              row.addRow = false
              this.requestBodyTableFormData.push({
                addRow: true,
                parameterName: '',
                type: '',
                required: true,
                explain: '',
                limit: '',
                example: ''
              })
            }
            break
          case 'requestBodyTableJson':
            if (row.addRow) {
              row.addRow = false
              this.requestBodyTableJson.push({
                addRow: true,
                parameterName: '',
                type: '',
                required: true,
                explain: '',
                limit: '',
                example: ''
              })
            }
            break
          case 'requestBodyTableQuery':
            if (row.addRow) {
              row.addRow = false
              this.requestBodyTableQuery.push({
                name: '', // 名称
                type: '', // 类型
                required: '', // 是否必填（0否，1是）
                verification: '', // 限制
                remarks: '', // 说明
                demo: '', // 示例
                minLength: '', // 最小长度
                maxLength: '', // 最大长度
                defaultValue: '', // 默认值
                addRow: true
              })
            }
            break
          case 'requestBodyTableREST':
            if (row.addRow) {
              row.addRow = false
              this.requestBodyTableREST.push({
                name: '', // 名称
                type: '', // 类型
                required: '', // 是否必填（0否，1是）
                verification: '', // 限制
                remarks: '', // 说明
                demo: '', // 示例
                minLength: '', // 最小长度
                maxLength: '', // 最大长度
                defaultValue: '', // 默认值
                addRow: true
              })
            }
            break
        }
      },
      removeRow(index, tableDom) {
        switch (tableDom) {
          case 'tableData':
            this.tableData.splice(index, 1)
            break
          case 'requestBodyTableFormData':
            this.requestBodyTableFormData.splice(index, 1)
            break
          case 'requestBodyTableJson':
            this.requestBodyTableJson.splice(index, 1)
            break
          case 'requestBodyTableQuery':
            this.requestBodyTableQuery.splice(index, 1)
            break
          case 'requestBodyTableREST':
            this.requestBodyTableREST.splice(index, 1)
            break
        }
      }
    }
  }
</script>

<style scoped>

</style>
